package com.itgaohe.controller;

import com.itgaohe.pojo.User;
import com.itgaohe.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Classname UserController
 * @Description
 * @Date 2025/3/23 12:05
 * @Created by 湖北彭于晏
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @PutMapping
    public boolean update(@RequestBody User user){
        return userService.updateById(user);
    }

    @PostMapping
    public boolean add(User user){
        return userService.save(user);
    }

    @DeleteMapping
    public boolean delete(@PathVariable Integer id){
        return userService.removeById(id);
    }

    @GetMapping("/{id}")
    public User getById(@PathVariable Integer id){
        return userService.getById(id);
    }

}